
/*
 * @Descripttion:
 * @version:
 * @Author: cxguo
 * @Date: 2019-10-18 15:37:24
 * @LastEditors  : cxguo
 * @LastEditTime : 2019-12-26 17:17:56
 */
export default {
  methods: {
    setTableData(dataArr) {
      this.tableData = dataArr
    },
    /**
     * 获取要保存的数据
     */
    getPostData() {
      const tableData = this.getTableData().tableData
      const postData = tableData.filter(item => { return item._sure })
      console.log('postData:', postData)
      return postData
    },
    valiData() {
      const postData = this.getPostData()
      return new Promise((resolve, reject) => {
        this.$refs.table.validate(postData, valid => {
          if (!valid) return reject(new Error('表格数据验证失败!'))
          resolve(true)
        }).catch(err => {
          reject(err)
        })
      })
    }
  }
}

